/*
 * OptimalAlgo.h
 *
 *  Created on: Jan 7, 2012
 *      Author: Shimi
 */
#pragma once

#include "TimeSliceCalculations.h"
#include "Sorter.h"
#include "Writer.h"
#include "Parser.h"
#include <list>
#include <map>
using namespace std;

class Algorithm
{

protected:
	SystemView* sys;
	TimeSliceCalculations* timeSliceCalc;	// calculates response time and damage
	Parser* parser;		// reads the time slices
	Sorter* sorter;		// different sorting algorithms
	Writer* writer;		// writes to output files
	vector<ExtentStatsAlgo*> *ssdExtents, *fcExtents, *sataExtents;		// describes the extents in each device
	DeviceData *ssd , *fc ,*sata;		// different devices
	map<int, double>* all_damages;
	// for the division output
	map<int,double>* ssdDivisionPercGroup1;
	map<int,double>* fcDivisionPercGroup1;
	map<int,double>* sataDivisionPercGroup1;
	map<int,double>* ssdDivisionPercGroup2;
	map<int,double>* fcDivisionPercGroup2;
	map<int,double>* sataDivisionPercGroup2;
	map<int,double>* ssdDivisionPercGroup3;
	map<int,double>* fcDivisionPercGroup3;
	map<int,double>* sataDivisionPercGroup3;

	ofstream out, outNoPriority;
	void WritePlacements(vector<ExtentStatsAlgo*> *ssdExtents, vector<ExtentStatsAlgo*> *fcExtents, vector<ExtentStatsAlgo*> *sataExtents, int time);
	void WritePlacementsNoPriority(vector<ExtentStatsAlgo*> *ssdExtents, vector<ExtentStatsAlgo*> *fcExtents, vector<ExtentStatsAlgo*> *sataExtents, int time);

public:
	// describe the activity vector
	map<string, ExtentStatsAlgo*>* sortedExtents;
	vector<ExtentStatsAlgo*>* sortedAlgo;

	Algorithm(SystemView*, int, Writer*, Parser*);
	virtual ~Algorithm(void);
	virtual void runAlgo(int iteration) = 0;
	map<int, double>* getDamage() {return all_damages;};
};

